﻿﻿﻿﻿<%@ page contentType="text/html; charset=utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<c:set var="basePath" value="${pageContext.request.contextPath}" />
<div id="createDialog" class="crudDialog">
	<form id="createForm" method="post">
		<input type="hidden" name="userId" value="1">
		<div class="row">
			<div class="col-sm-12">
				<div class="form-group">
					<div class="fg-line">
						<label for="name">名称</label> <input id="name" type="text"
							class="form-control" name="name" maxlength="200">
					</div>
				</div>
			</div>
			<div class="col-sm-12">
				<div class="form-group">
					<div class="fg-line">
						<label for="remark">备注</label> <input id="remark" type="text"
							class="form-control" name="remark" maxlength="200">
					</div>
				</div>
			</div>
			<div class="col-sm-12">
				<div class="form-group">
					<div class="fg-line">
						<label for="type">规格类型(1：文字，2：图片)</label> <input id="type"
							type="text" class="form-control" name="type" maxlength="200">
					</div>
				</div>
			</div>
			<div class="col-sm-12">
				<div class="form-group">
					<div class="fg-line">
						<label for="sort">排序</label> <input id="sort" type="text"
							class="form-control" name="sort" maxlength="200">
					</div>
				</div>
			</div>
		</div>

		<div class="form-group text-right dialog-buttons">
			<a class="waves-effect waves-button" href="javascript:;"
				onclick="createSubmit();">保存</a> <a
				class="waves-effect waves-button" href="javascript:;"
				onclick="createDialog.close();">取消</a>
		</div>
	</form>
</div>
<script>
	function createSubmit() {
		$
				.ajax({
					type : 'post',
					url : '${basePath}/manage/spec/create',
					data : $('#createForm').serialize(),
					beforeSend : function() {
						if ($('#title').val() == '') {
							$('#title').focus();
							return false;
						}
					},
					success : function(result) {
						if (result.code != 1) {
							if (result.data instanceof Array) {
								$
										.each(
												result.data,
												function(index, value) {
													$
															.confirm({
																theme : 'dark',
																animation : 'rotateX',
																closeAnimation : 'rotateX',
																title : false,
																content : value.errorMsg,
																buttons : {
																	confirm : {
																		text : '确认',
																		btnClass : 'waves-effect waves-button waves-light'
																	}
																}
															});
												});
							} else {
								$
										.confirm({
											theme : 'dark',
											animation : 'rotateX',
											closeAnimation : 'rotateX',
											title : false,
											content : result.data.errorMsg,
											buttons : {
												confirm : {
													text : '确认',
													btnClass : 'waves-effect waves-button waves-light'
												}
											}
										});
							}
						} else {
							createDialog.close();
							$table.bootstrapTable('refresh');
						}
					},
					error : function(XMLHttpRequest, textStatus, errorThrown) {
						$
								.confirm({
									theme : 'dark',
									animation : 'rotateX',
									closeAnimation : 'rotateX',
									title : false,
									content : textStatus,
									buttons : {
										confirm : {
											text : '确认',
											btnClass : 'waves-effect waves-button waves-light'
										}
									}
								});
					}
				});
	}
</script>